package com.lwy.qiuchao.safety.controller;

import java.util.Arrays;
import java.util.Map;

import com.lwy.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.lwy.qiuchao.safety.entity.SafetyBoxEntity;
import com.lwy.qiuchao.safety.service.SafetyBoxService;
import com.lwy.common.utils.PageUtils;


/**
 * 
 *
 * @author lwy
 * @email ${email}
 * @date 2020-12-01 15:47:38
 */
@RestController
@RequestMapping("safety/safetybox")
public class SafetyBoxController {
    @Autowired
    private SafetyBoxService safetyBoxService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = safetyBoxService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{sbId}")
    public R info(@PathVariable("sbId") Long sbId){
		SafetyBoxEntity safetyBox = safetyBoxService.getById(sbId);

        return R.ok().put("safetyBox", safetyBox);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody SafetyBoxEntity safetyBox){
		safetyBoxService.save(safetyBox);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody SafetyBoxEntity safetyBox){
		safetyBoxService.updateById(safetyBox);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] sbIds){
		safetyBoxService.removeByIds(Arrays.asList(sbIds));

        return R.ok();
    }

}
